package net.mingsoft.cms.action.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.bean.WxJsapiSignature;
import me.chanjar.weixin.mp.api.WxMpService;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.cms.action.BaseAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.net.URLDecoder;

/**
 * @Author guti
 * @Date 2025/3/5
 */
@Api(tags={"Weixin功能模块接口"})
@Controller("WeixinAction")
@RequestMapping("/app/weixin")
public class WeixinAction extends BaseAction {

    @Autowired
    private WxMpService wxMpService;
    /**
     * 微信公众号-获取签名接口
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "获取签名接口")
    @ApiImplicitParam(name = "url", value = "链接", required =true, paramType="query")
    @RequestMapping(value = "/getSignature", method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public ResultData getSignature(@RequestParam("url") String url) throws Exception {
        WxJsapiSignature wxJsapiSignature2 = this.wxMpService.createJsapiSignature(URLDecoder.decode(url,"UTF-8"));
        return ResultData.build().success(wxJsapiSignature2);
    }

}
